import { Inject, Controller, Get, Post, Body } from '@midwayjs/decorator';

import { Context } from '@midwayjs/koa';
import { UserUpdateDTO } from '@/dto/user';
import { UserService } from '../service/user.service';

@Controller('api/user')
export class UserController {
  @Inject()
  ctx: Context;

  @Inject()
  userService: UserService;

  @Get('/getUser')
  async getUser(): Promise<any> {
    const result = await this.userService.getUser();
    return result;
  }

  @Get('/getUserList')
  async getUserList(): Promise<any> {
    const result = await this.userService.getUserList();
    return result;
  }

  /**
   * 修改用户信息
   * @param updateUser
   */
  @Post('/updateUser')
  async updateUser(@Body() users: UserUpdateDTO): Promise<any> {
    const result = await this.userService.updateUser(users);
    return result;
  }
}
